package com.zw.user.controller;/*
 *@program:java-cloud-prevalence
 *@author:
 *@Time: 2022/12/6  23:38
 *@description: 用户服务调用系统服务控制类
 */

import com.zw.object.result.Result;
import com.zw.object.vo.AssginRoleVo;
import com.zw.user.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@Api(tags = "用户服务调用系统服务控制类")
@RestController()
@RequestMapping("/admin/system/sysUser")
public class UserSystemController {

    @Autowired
    private SysUserService sysUserService;

    /**
     *                  根据用户ID获取用户角色数据接口
     * @param userId    用户ID
     * @return          Result
     */
    @PreAuthorize("hasAnyAuthority('bnt.sysUser.assignRole')")
    @ApiOperation("根据用户ID获取用户角色数据")
    @GetMapping("/toAssign/{userId}")
    public Result toAssign(@PathVariable("userId") String userId){
        return sysUserService.toAssign(userId);
    }
    /**
     *                      根据用户ID分配角色接口
     * @param assginRoleVo  参数实体类对象
     * @return              Result
     */
    @ApiOperation("根据用户分配角色")
    @PostMapping("/doAssign")
    public Result doAssign(@RequestBody AssginRoleVo assginRoleVo){
        return sysUserService.saveUserRole(assginRoleVo);
    }
}
